<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use DB;
use Intervention\Image\ImageManagerStatic as Image;

class ConfigController extends Controller
{
    public function index()
    {
    	$list=DB::table("config")->get();
    	return view("admin.config.config",["list"=>$list]);
    }

    public function edit($id)
    {
    	$list = DB::table('config')->where('id',$id)->first();
    	return view('admin.config.edit',['config'=>$list]);
    }

    public function update($id,Request $request)
    {
    	$data = $request->only('title','keys','description','switch');
    	$row = DB::table('config')->where('id',$id)->update($data);
        $list=DB::table("config")->get();
    	if($row>0){
            return view("admin.config.config",["list"=>$list]);
        }else{
            return '修改失败';
        }
    }
}
